package cn.mw.cmdb.monitorview.controller;

import cn.mw.cmdb.link.entity.MwNetWorkLinkDto;
import cn.mw.cmdb.monitorview.entity.MwBladeDto;
import cn.mw.cmdb.monitorview.entity.MwKnifeBlockDto;
import cn.mw.cmdb.monitorview.param.MwKnifeBlockParam;
import cn.mw.cmdb.monitorview.service.MwKnifeBlockViewService;
import cn.mw.cmdb.timeplan.param.MwTimePlanParam;
import cn.mw.cmdb.view.ViewConvertContext;
import cn.mw.cmdb.view.ViewManager;
import cn.mw.microMonitorCommon.api.common.BaseApiService;
import cn.mw.microMonitorCommon.api.common.ResponseBase;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author gengjb
 * @description 刀框视图
 * @date 2024/9/3 10:25
 */
@RequestMapping("/knifeBlock/view")
@Controller
@Tag(name = "刀框视图")
@Slf4j
public class MwKnifeBlockViewController extends BaseApiService {

    private MwKnifeBlockViewService knifeBlockViewService;

    private ViewManager viewManager;

    public MwKnifeBlockViewController(MwKnifeBlockViewService knifeBlockViewService,ViewManager viewManager) {
        this.knifeBlockViewService = knifeBlockViewService;
        this.viewManager = viewManager;
    }

    @PostMapping("/getBladeInfo")
    @ResponseBody
    @Operation(summary = "获取刀片信息")
    public ResponseBase getBladeInfo(@RequestBody MwKnifeBlockParam knifeBlockParam) throws Exception {
        List<MwBladeDto> bladeInfo = knifeBlockViewService.getBladeInfo(knifeBlockParam);
        //分页
        Object pageRet = viewManager.getListViewObject(bladeInfo, MwKnifeBlockParam.class, knifeBlockParam, new ViewConvertContext());
        return setResultSuccess(pageRet);
    }


    @PostMapping("/getKnifeBlockInfo")
    @ResponseBody
    @Operation(summary = "获取刀框基础监控信息")
    public ResponseBase getKnifeBlockBasicMonitorInfo(@RequestBody MwKnifeBlockParam knifeBlockParam) throws Exception {
        MwKnifeBlockDto basicMonitorInfo = knifeBlockViewService.getKnifeBlockBasicMonitorInfo(knifeBlockParam);
        return setResultSuccess(basicMonitorInfo);
    }

    @PostMapping("/getAllBladeBasicInfo")
    @ResponseBody
    @Operation(summary = "获取所有刀片基础监控信息")
    public ResponseBase getAllBladeBasicInfo(@RequestBody MwKnifeBlockParam knifeBlockParam) throws Exception {
        List<MwBladeDto> allBladeBasicInfo = knifeBlockViewService.getAllBladeBasicInfo(knifeBlockParam);
        return setResultSuccess(allBladeBasicInfo);
    }
}
